package user_v1

import (
	"context"
	"errors"
	"gf-xb-api/internal/dao"
	"gf-xb-api/internal/model/dto"
	"gf-xb-api/internal/model/entity"
)

func (s *sUser) GetUserInfo(ctx context.Context, in *dto.UserLoginInput) (output *dto.UserLoginOutput, err error) {

	var user *entity.SysUser

	err = dao.SysUser.Ctx(ctx).Where(dao.SysUser.Columns().Username, in.Username).Scan(&user)
	if err != nil {
		return nil, err
	}

	if user == nil {
		return nil, errors.New("用户名或密码不正确")
	}

	output = &dto.UserLoginOutput{
		Id:   user.Id,
		Uuid: user.Uuid,
	}

	return output, nil
}
